/**
 * 
 */
package com.skood.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author keege
 *
 */
public class ExecuteResult<T> implements Serializable{
	private static final long serialVersionUID = 1L;

	private T result;
	/**
	 * 成功提示消息
	 */
	private String successMessage;
	/**
	 * 普通的错误信息
	 */
	private List<String> errorMessages = new ArrayList<String>();
	/**
	 * 字段错误信息-以key-value的形式出现
	 */
	private Map<String, String> fieldErrors = new HashMap<String, String>();
	/**
	 * 警告信息
	 */
	private List<String> warningMessages = new ArrayList<String>();
	/**
	 * 普通的错误信息和字段错误信息都为空返回 true,表示执行结果成功
	 * @return
	 */
	public boolean isSuccess() {
		return errorMessages.isEmpty() && fieldErrors.isEmpty();
	}
	/**
	 * 添加错误提示信息
	 * @param message 提示信息
	 */
	public void addErrorMessages(String message){
		this.errorMessages.add(message);
	}
	/**
	 * 添加字段错误提示信息
	 * @param field 对应字段
	 * @param message 提示信息
	 */
	public void addFieldErrors(String field,String message){
		
	}
	/**
	 * 添加警告提示信息
	 * @param message
	 */
	public void addWarningMessages(String message){
		this.warningMessages.add(message);
	}
	public T getResult() {
		return result;
	}

	public void setResult(T result) {
		this.result = result;
	}

	public String getSuccessMessage() {
		return successMessage;
	}

	public void setSuccessMessage(String successMessage) {
		this.successMessage = successMessage;
	}

	public List<String> getErrorMessages() {
		return errorMessages;
	}

	public void setErrorMessages(List<String> errorMessages) {
		this.errorMessages = errorMessages;
	}

	public Map<String, String> getFieldErrors() {
		return fieldErrors;
	}

	public void setFieldErrors(Map<String, String> fieldErrors) {
		this.fieldErrors = fieldErrors;
	}

	public List<String> getWarningMessages() {
		return warningMessages;
	}

	public void setWarningMessages(List<String> warningMessages) {
		this.warningMessages = warningMessages;
	}

	
	
}
